package com.my.main.component.interceptor;
/*
 * -
 *
 * @ author jiaxd 2020-05-27
 */


public class ContextInfo {

    private static ThreadLocal<String> ip = new ThreadLocal<>();
    private static ThreadLocal<String> uri = new ThreadLocal<>();
    private static ThreadLocal<String> sessionId = new ThreadLocal<>();

    public static void set(String key, String value) {
        if (key.equals("ip")) {
            ip.set(value);
        }
        else if (key.equals("uri")) {
            uri.set(value);
        }
        else if (key.equals("sessionId")) {
            sessionId.set(value);
        }
    }

    public static String get(String key) {
        if (key.equals("ip")) {
            return ip.get();
        }
        else if (key.equals("uri")) {
            return uri.get();
        }
        else if (key.equals("sessionId")) {
            return sessionId.get();
        }

        return null;
    }

}
